package com.edu.tool.controller.core;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.edu.tool.annotation.NotCheckToken;
import com.edu.tool.bc.SysBcDef;
import com.edu.tool.bc.SysBusComp;
import com.edu.tool.bean.uidef.SysApplet;
import com.edu.tool.bean.uidef.SysApplication;
import com.edu.tool.bean.user.SysResp;
import com.edu.tool.constant.MsgConstant;
import com.edu.tool.constant.StaticConstant;
import com.edu.tool.mapper.bc.SysBCMapper;
import com.edu.tool.mapper.uidef.SysAppletMapper;
import com.edu.tool.mapper.user.SysReponsibilityMapper;
import com.edu.tool.service.uidef.SysAppService;
import com.edu.tool.util.MsgUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

@RequestMapping(value = "/api/uidef")
@RestController
@Api(value="对象定义Controller")
public class SysObjectDefController {



    @Autowired
    private SysAppService sysAppService;

    @Autowired
    private SysBCMapper bcMapper;


    @Autowired
    private SysAppletMapper appletMapper;

    @Autowired
    private SysReponsibilityMapper reponsibilityMapper;


    @ApiOperation(value="测试用接口", notes="测试用接口" ,httpMethod="GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="offset", value="应用的名称", dataType = "String", required=true, paramType="path"),
            @ApiImplicitParam(name="limit", value="应用的语言", dataType = "String", required=true, paramType="path")
    })
    @GetMapping(value = "/app")
    @RequiresAuthentication
    public Map getApps(@RequestParam Integer offset, @RequestParam Integer limit){

        try{
            IPage<SysApplication> sysApplication  = sysAppService.findItemByPage(offset,limit);



            //String strSysApp = JsonUtil.toJson(sysApplication);
            return MsgUtil.retMap( StaticConstant.APPLICATIONS, sysApplication);
        }catch(Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }

    @ApiOperation(value="测试用接口", notes="测试用接口" ,httpMethod="GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="name", value="应用的名称", dataType = "String", required=true, paramType="path"),
            @ApiImplicitParam(name="lang", value="应用的语言", dataType = "String", required=true, paramType="path")
    })
    @GetMapping(value = "/app/{name}/{lang}")
    @RequiresAuthentication
    public Map getAppByNameAndLang(@PathVariable("name") String name,
                               @PathVariable("lang") String lang){

        try{
            //SysApplication sysApplication  = sysAppService.getObjectById(id);
            if(name.equals("login")) {


                /** page1 definition **/
                Map page1Map = new HashMap();
                page1Map.put("name","login page");
                page1Map.put("path","login");
                page1Map.put("component","pages/login/login");
                page1Map.put("type","page");

                /** page2 definition **/
                Map page2Map = new HashMap();
                page2Map.put("name","register page");
                page2Map.put("path","register");
                page2Map.put("component","pages/login/register");
                page2Map.put("type","page");

                ArrayList pageList = new ArrayList();
                pageList.add(page1Map);
                pageList.add(page2Map);

                Map sysApplication = new HashMap();
                sysApplication.put("name","login");
                sysApplication.put("path","/");
                sysApplication.put("component","applayout/login/LoginApp");

                sysApplication.put("type","application");
                sysApplication.put("children",pageList);

                sysApplication.put("defaultscreen","login");
                return MsgUtil.retMap( StaticConstant.APPLICATION, sysApplication);
            }

            if(name.equals("backendmanagesystem")) {

                Map metaMap = new HashMap();
                metaMap.put("title","系统首页");

                /** page1 definition **/
                Map page1Map = new HashMap();
                page1Map.put("name","dashboard");
                page1Map.put("path","dashboard");
                page1Map.put("component","pages/managesystem/Dashboard");
                page1Map.put("type","page");
                page1Map.put("meta",metaMap);

                /** page2 definition **/
                Map page2Map = new HashMap();
                page2Map.put("name","icon");
                page2Map.put("path","icon");
                page2Map.put("component","pages/managesystem/Icon");
                page2Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","自定义图标");
                page2Map.put("meta",metaMap);

                /** page3 definition **/
                Map page3Map = new HashMap();
                page3Map.put("name","baseform");
                page3Map.put("path","baseform");
                page3Map.put("component","pages/managesystem/BaseForm");
                page3Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","基本表单");
                page3Map.put("meta",metaMap);

                /** page4 definition **/
                Map page4Map = new HashMap();
                page4Map.put("name","basetable");
                page4Map.put("path","basetable");
                page4Map.put("component","pages/managesystem/BaseTable");
                page4Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","基本表格");
                page4Map.put("meta",metaMap);

                /** page5 definition **/
                Map page5Map = new HashMap();
                page5Map.put("name","dragList");
                page5Map.put("path","dragList");
                page5Map.put("component","pages/managesystem/DragList");
                page5Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","拖拽列表");
                metaMap.put("group","dragGroup");
                page5Map.put("meta",metaMap);

                /** page6 definition **/
                Map page6Map = new HashMap();
                page6Map.put("name","dragDialog");
                page6Map.put("path","dragDialog");
                page6Map.put("component","pages/managesystem/DragDialog");
                page6Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","拖拽对话框");
                metaMap.put("group","dragGroup");
                page6Map.put("meta",metaMap);

                /** page7 definition **/
                Map page7Map = new HashMap();
                page7Map.put("name","yapplication");
                page7Map.put("path","myapplication");
                page7Map.put("component","pages/managesystem/MyApplication");
                page7Map.put("type","page");

                metaMap = new HashMap();
                metaMap.put("title","我的应用程序");
                page7Map.put("meta",metaMap);


                ArrayList pageList = new ArrayList();
                pageList.add(page1Map);
                pageList.add(page2Map);
                pageList.add(page3Map);
                pageList.add(page4Map);
                pageList.add(page5Map);
                pageList.add(page6Map);

                Map sysApplication = new HashMap();
                sysApplication.put("name","homepage");
                sysApplication.put("path","/");
                sysApplication.put("component","applayout/managesystem/Home");

                sysApplication.put("type","application");

                sysApplication.put("children",pageList);

                sysApplication.put("defaultscreen","dashboard");
                return MsgUtil.retMap( StaticConstant.APPLICATION, sysApplication);
            }
            if(name.equals("tools")) {

                /** page1 definition **/
                Map page1Map = new HashMap();
                page1Map.put("name","editor page");
                page1Map.put("path","editor");
                page1Map.put("component","pages/tools/editor/index");
                page1Map.put("type","page");

                /** page2 definition **/
                Map page2Map = new HashMap();
                page2Map.put("name","preview page");
                page2Map.put("path","preview");
                page2Map.put("component","pages/tools/preview/preview");
                page2Map.put("type","page");

                ArrayList pageList = new ArrayList();
                pageList.add(page1Map);
                pageList.add(page2Map);

                Map sysApplication = new HashMap();
                sysApplication.put("name","tools");
                sysApplication.put("path","/");
                sysApplication.put("component","applayout/tools/App");

                sysApplication.put("type","application");


                sysApplication.put("children",pageList);

                sysApplication.put("defaultscreen","editor");
                return MsgUtil.retMap( StaticConstant.APPLICATION, sysApplication);
            }

            /** screen1 definition **/
            Map metaMap = new HashMap();
            metaMap.put("requireAuth","true");

            Map screen1Map = new HashMap();


            screen1Map.put("name","account screen");
            screen1Map.put("path","accountscreen");
            screen1Map.put("component","screenlayouts/accountscreen");
            screen1Map.put("type","screen");
            screen1Map.put("meta",metaMap);

            Map screen1v1Map = new HashMap();
            screen1v1Map.put("name","account List");
            screen1v1Map.put("path","accountlist");
            screen1v1Map.put("component","views/accountlist");
            screen1v1Map.put("type","view");
            screen1v1Map.put("meta",metaMap);


            Map screen1v2Map = new HashMap();
            screen1v2Map.put("name","Account Detail");
            screen1v2Map.put("path","accountdetail");
            screen1v2Map.put("component","views/accountdetail");
            screen1v2Map.put("type","view");
            screen1v2Map.put("meta",metaMap);

            ArrayList screen1viewlist = new ArrayList();
            screen1viewlist.add(screen1v1Map);
            screen1viewlist.add(screen1v2Map);

            screen1Map.put("children",screen1viewlist);
            screen1Map.put("defaultview","accountlist");

            /** screen2 definition **/
            Map screen2Map = new HashMap();
            screen2Map.put("name","contact screen");
            screen2Map.put("path","contact");
            screen2Map.put("component","screenlayouts/contactscreen");
            screen2Map.put("type","screen");
            screen2Map.put("meta",metaMap);

            Map screen2v1Map = new HashMap();
            screen2v1Map.put("name","Contact List");
            screen2v1Map.put("path","contactlist");
            screen2v1Map.put("component","views/contactlist");
            screen2v1Map.put("type","view");
            screen2v1Map.put("meta",metaMap);


            Map screen2v2Map = new HashMap();
            screen2v2Map.put("name","Contact Detail");
            screen2v2Map.put("path","contactdetail");
            screen2v2Map.put("component","views/contactdetail");
            screen2v2Map.put("type","view");
            screen2v2Map.put("meta",metaMap);

            ArrayList screen2viewlist = new ArrayList();
            screen2viewlist.add(screen2v1Map);
            screen2viewlist.add(screen2v2Map);

            screen2Map.put("children",screen2viewlist);
            screen2Map.put("defaultview","contactlist");

            Map sysApplication = new HashMap();
            sysApplication.put("name","CallCenter");
            sysApplication.put("path","/");
            sysApplication.put("component","applayout/index");

            sysApplication.put("type","application");


            ArrayList screenList = new ArrayList();
            screenList.add(screen1Map);
            screenList.add(screen2Map);

            sysApplication.put("children",screenList);
            sysApplication.put("defaultscreen","accountscreen");


            //String strSysApp = JsonUtil.toJson(sysApplication);
            return MsgUtil.retMap( StaticConstant.APPLICATION, sysApplication);
        }catch(Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }



    @ApiOperation(value="获取UI Widget", notes="获取UI Widget" ,httpMethod="GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="name", value="widget的名称", dataType = "String", required=true, paramType="path"),
            @ApiImplicitParam(name="lang", value="widget的语言", dataType = "String", required=true, paramType="path")
    })
    @GetMapping(value = "/uiwidget/{name}/{lang}")
    @RequiresAuthentication
    public Map getUIWidget(@PathVariable("name") String name,
                           @PathVariable("lang") String langt){

        try{

            /** page1 definition **/
            Map widgetMap = new HashMap();
            widgetMap.put("name","MyApplication");
            widgetMap.put("html","");
            widgetMap.put("script","");
            widgetMap.put("style","");
            widgetMap.put("template","template/BaseTable");
            widgetMap.put("type","page");

            //String strSysApp = JsonUtil.toJson(sysApplication);
            return MsgUtil.retMap( StaticConstant.WIDGET, widgetMap );
        }catch(Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }

    @RequestMapping(value = "/bcdef/contact", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试contact bc 的创建")
    @NotCheckToken
    public Object testbcdefUpdateAndInsert(HttpServletRequest request,
                                           @RequestParam String name


    )
    {
        SysBcDef contactBcDef = SysBcDef.getBc("contact");
        SysBusComp contactBusComp = new SysBusComp(contactBcDef);
        contactBusComp.setFieldValue("id",1255);
        contactBusComp.setFieldValue("contact name","contact1");
        contactBusComp.setFieldValue("first name","xiongjian");
        contactBusComp.create();

        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"contact 创建成功。");
    }

    @RequestMapping(value = "/bcdef/contact", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试Contact的查询")
    @NotCheckToken
    public Object testbcdefQuery(HttpServletRequest request,
                                 @RequestParam String name


    )
    {
        SysBcDef contactBcDef = SysBcDef.getBc("contact");
        SysBusComp contactBusComp = new SysBusComp(contactBcDef);
        contactBusComp.activeField("contact name");
        contactBusComp.activeField("first name");

        contactBusComp.setFieldValue("contact name","contact1");
        contactBusComp.setFieldValue("first name","xiongjian");
        List<Map<String,Object>> contacts = contactBusComp.executeQuery();


        return MsgUtil.retMap("contacts",contacts);
    }


    @RequestMapping(value = "/bcdef/contact", method = RequestMethod.DELETE)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试基于Id的删除contact")
    @NotCheckToken
    @Transactional
    public Object testbcdefDelete(HttpServletRequest request,
                                  @RequestParam String name


    )
    {
        SysBcDef contactBcDef = SysBcDef.getBc("contact");
        SysBusComp contactBusComp = new SysBusComp(contactBcDef);
        contactBusComp.setFieldValue("id",1256);

        contactBusComp.deleteById();


        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"delete contact Successfully.");
    }

    @RequestMapping(value = "/responsibility", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "responsibility", notes = "添加responsibility")
    @NotCheckToken
    public Object responsibility(HttpServletRequest request,
                                 @RequestParam String name


    )
    {
        SysResp responsibility = new SysResp();
        responsibility.setName(name);
        responsibility.setDescription("管理员");
        String uuid = UUID.randomUUID().toString();
        responsibility.setUuid(uuid);
        responsibility.setTenantId(1);
        reponsibilityMapper.insert(responsibility);

        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"responsibility 创建成功。");
    }


    //
    @RequestMapping(value = "/bcdef/organization", method = RequestMethod.PUT)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试organization bc 的更新")
    @NotCheckToken
    public Object createOrganization(HttpServletRequest request,
                                     @RequestParam String name


    )
    {
        SysBcDef orgBcDef = SysBcDef.getBc("Organization");
        SysBusComp orgnizationBusComp = new SysBusComp(orgBcDef);

        orgnizationBusComp.setFieldValue("Party Name","面向企业软件开发北京总部");
        orgnizationBusComp.setFieldValue("Name","面向企业软件开发北京总部");
        //orgnizationBusComp.setFieldValue("Parent Organization Id",1259 );
        orgnizationBusComp.setFieldValue("Currency Code","CNY");
        orgnizationBusComp.setFieldValue("Internal Org Flag","Y");
        orgnizationBusComp.setFieldValue("Partner Flag","N");
        orgnizationBusComp.setFieldValue("Organization Flag","Y");
        orgnizationBusComp.create();

//
//        orgnizationBusComp.setFieldValue("Party Name","面向企业软件开发杭州分部");
//        orgnizationBusComp.setFieldValue("Name","面向企业软件开发杭州分部");
//        //orgnizationBusComp.setFieldValue("Parent Organization Id",1259 );
//        orgnizationBusComp.setFieldValue("Currency Code","CNY");
//        orgnizationBusComp.setFieldValue("Internal Org Flag","Y");
//        orgnizationBusComp.setFieldValue("Partner Flag","N");
//        orgnizationBusComp.setFieldValue("Organization Flag","Y");
//        orgnizationBusComp.create();



        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"Organization 创建成功。");
    }

    //
    @RequestMapping(value = "/bcdef/organization", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试organization bc 的创建")
    @NotCheckToken
    public Object updateOrganization(HttpServletRequest request,
                                     @RequestParam String name)
    {
        SysBcDef orgBcDef = SysBcDef.getBc("Organization");
        SysBusComp ParOrgnizationBusComp = new SysBusComp(orgBcDef);
        ParOrgnizationBusComp.activeField("Name");

        ParOrgnizationBusComp.setFieldValue("Name","面向企业软件开发北京总部");
        List<Map<String,Object>> orgs = ParOrgnizationBusComp.executeQuery();
//
//        orgnizationBusComp.setFieldValue("Party Name","面向企业软件开发杭州分部");
//        orgnizationBusComp.setFieldValue("Name","面向企业软件开发杭州分部");
//        //orgnizationBusComp.setFieldValue("Parent Organization Id",1259 );
//        orgnizationBusComp.setFieldValue("Currency Code","CNY");
//        orgnizationBusComp.setFieldValue("Internal Org Flag","Y");
//        orgnizationBusComp.setFieldValue("Partner Flag","N");
//        orgnizationBusComp.setFieldValue("Organization Flag","Y");
//        orgnizationBusComp.create();


        SysBusComp organizationBusComp = new SysBusComp(orgBcDef);
        organizationBusComp.activeField("Name");


        organizationBusComp.setFieldValue("Name","面向企业软件开发杭州分部");

        List<Map<String,Object>> orgs1 = organizationBusComp.executeQuery();

        organizationBusComp.setFieldValue("id",orgs1.get(0).get("id"));
        organizationBusComp.setFieldValue("Parent Organization Id",orgs.get(0).get("id"));
        organizationBusComp.updateById();

        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"Organization 创建成功。");
    }



    @RequestMapping(value = "/bcdef/position", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "职位的创建")
    @NotCheckToken
    public Object createPosition(HttpServletRequest request,
                                 @RequestParam String name


    )
    {
        SysBcDef positionBcDef = SysBcDef.getBc("Position");
        SysBusComp positionBusComp = new SysBusComp(positionBcDef);

        positionBusComp.setFieldValue("Party Name","总经理");
        positionBusComp.setFieldValue("Name","总经理");

        SysBcDef orgBcDef = SysBcDef.getBc("Organization");
        SysBusComp ParOrgnizationBusComp = new SysBusComp(orgBcDef);
        ParOrgnizationBusComp.activeField("Name");

        ParOrgnizationBusComp.setFieldValue("Name","面向企业软件开发北京总部");
        List<Map<String,Object>> orgs = ParOrgnizationBusComp.executeQuery();

        //orgnizationBusComp.setFieldValue("Parent Organization Id",1259 );
        positionBusComp.setFieldValue("Currency Code","CNY");

        positionBusComp.create();


        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"Organization 创建成功。");
    }

    @RequestMapping(value = "/testautoid", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "bcdef", notes = "测试bc")
    @NotCheckToken
    public Object testautoid(HttpServletRequest request,
                             @RequestParam String name


    )
    {
        HashMap<String,Object> col2ValMap = new HashMap<>();
        Date now = new Date();
        col2ValMap.put("create_time",now);
        col2ValMap.put("create_by","admin");
        col2ValMap.put("update_time",now);
        col2ValMap.put("update_by","admin");
        col2ValMap.put("partyTypeCd","person");
        col2ValMap.put("partyUID",1);
        col2ValMap.put("name","testcontact");

        //Record record = new Record();
        //record.setTableName("s_party");
        //record.setColValMap(col2ValMap);
        col2ValMap.put("table","s_party");
        bcMapper.Insert2(col2ValMap);

        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"字典创建成功。");
    }


    @RequestMapping(value = "/applet", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "applet", notes = "测试bc")
    @NotCheckToken
    public Object test(HttpServletRequest request,
                       @RequestParam String name


    )
    {
        SysApplet sysApplet = new SysApplet();

//        sysApplet.setLayout("table");
//        sysApplet.setTitle("contact applet");
//
//        Date now = new Date();
//        sysApplet.setCreate_by("ruixj");
//        sysApplet.setCreate_time(now);
//        sysApplet.setUpdate_by("ruixj");
//        sysApplet.setUpdate_time(now);
//
//        appletMapper.insert(sysApplet);


        QueryWrapper<SysApplet> appletQR = new QueryWrapper<>();
        appletQR.lambda().eq(SysApplet::getTitle, "contact applet");

        sysApplet = appletMapper.selectOne(appletQR);

        return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"字典创建成功。");
    }
    @ApiOperation(value="测试用接口", notes="测试用接口" ,httpMethod="GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="name", value="应用的名称", dataType = "String", required=true, paramType="path"),
            @ApiImplicitParam(name="lang", value="应用的语言", dataType = "String", required=true, paramType="path")
    })

    @GetMapping(value = "/view/{name}/{lang}/applets")
    @RequiresAuthentication
    public  Map getViewApplets(@PathVariable("name") String name,
                                   @PathVariable("lang") String lang){

        try{


            ArrayList viewAppletlist = new ArrayList();
            viewAppletlist.add("applets/table/index");
            viewAppletlist.add("applets/form/index");

            return MsgUtil.retMap(StaticConstant.VIEW, viewAppletlist);
        }catch(Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }



    @PostMapping(value = "/app")
    //@RequiresAuthentication
    public  Map addApp(
                           @RequestBody SysApplication sysApplication
                                ){

        try{
             Integer r = sysAppService.add(sysApplication );

            if(r > 0){

                return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"Successfully add application");
            }else{
                return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,"Failed to add application");
            }
        }catch (org.springframework.dao.DuplicateKeyException e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }catch (Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }

    @PutMapping(value = "/app")
    @RequiresAuthentication
    public Map update (  @RequestBody SysApplication sysApplication){

        Integer i = sysAppService.update(sysApplication);

        if(i > 0 ){
            return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"successfully updated");
        }
        else{
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,"failed to update ");

        }

    }

    @DeleteMapping(value = "/app")
    @RequiresAuthentication
    public  Map delete (@RequestParam Integer id){


        Integer i = sysAppService.delete(id);
        if(i > 0 ){
            return MsgUtil.retMsgMap(MsgConstant.SUCCESS_RET,"successfully deleted");
        }
        else{
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,"failed to delete ");

        }
    }

    @ApiOperation(value="测试用接口", notes="测试用接口" ,httpMethod="GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pagenum", value="应用的名称", dataType = "String", required=true, paramType="query"),

    })
    @GetMapping(value = "/service/tabledata/")
    @RequiresAuthentication
    public Map GetTableData(@RequestParam("pagenum") String pageNum ){

        try{
            Map sysPersons = new HashMap();


            ArrayList recordList = new ArrayList();

            Map<String,Object> record1 = new HashMap<>();
            record1.put("name","xiongjian");
            record1.put("sex","male");
            record1.put("age","20");
            recordList.add(record1);

            Map<String,Object> record2 = new HashMap<>();
            record1.put("name","xiongjian");
            record1.put("sex","male");
            record1.put("age","20");

            recordList.add(record2);

            sysPersons.put("records",recordList);


            return  MsgUtil.retMap( StaticConstant.TABLERECORDS, sysPersons);
        }catch(Exception e){
            return MsgUtil.retMsgMap(MsgConstant.FAILED_RET,e.getMessage());
        }

    }
}
